﻿using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using TouchSocket.Core;
using TouchSocket.Dmtp;
using TouchSocket.Dmtp.Rpc;
using TouchSocket.Rpc;
using TouchSocket.Sockets;

namespace Client;

/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }

    private IDmtpRpcActor _rpc;
    private void Button_Click(object sender, RoutedEventArgs e)
    {
        var client = new TcpDmtpClient();
        client.Setup(new TouchSocketConfig()
          .SetRemoteIPHost("127.0.0.1:3080")
          .ConfigurePlugins(a =>
              {
                  a.UseDmtpRpc();
              })
          .SetDmtpOption(new DmtpOption()
          {
              VerifyToken = "Dmtp"
          }));
        client.Connect();
        _rpc = client.GetDmtpRpcActor();
    }

    private void Button_Click_1(object sender, RoutedEventArgs e)
    {
        var data = _rpc.InvokeT<bool>("M1", null, InvokeOption.WaitInvoke, "123", "abc");
    }

    private void Button_Click_2(object sender, RoutedEventArgs e)
    {
        _rpc.Invoke("M2", null, InvokeOption.WaitInvoke, "1", "2");
    }
    
    private void Button_Click_3(object sender, RoutedEventArgs e)
    {
        _rpc.InvokeT<bool>("M3", null, InvokeOption.WaitInvoke);
    }
    private void Button_Click_4(object sender, RoutedEventArgs e)
    {
        _rpc.Invoke("M4", null, InvokeOption.WaitInvoke);
    }
}